// 查询字典列表
export default defineEventHandler(async (event) => {
  const code = getRouterParam(event, "code");
  try {
    const res_list = await DicSchema.find({
      code: code,
    }).lean();
    if (Array.isArray(res_list) && res_list.length > 0) {
      return JSON.parse(res_list[0].list).map((item: any) => ({
        label: item.label,
        value: item.code,
      }));
    } else {
      return [];
    }
  } catch (error) {
    throw createError({
      statusCode: 500,
      statusMessage: "查询字典信息失败",
    });
  }
});
